package com.pg.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pg.entity.ycl.EipNozzle;
import com.pg.mapper.EipNozzleMapper;
import com.pg.service.EipNozzleService;
import com.pg.utils.Jpg2Base64Util;
import com.pg.utils.UploadFileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 断路器喷口 服务实现类
 * </p>
 *
 * @Author likl
 * @since 2020-10-26
 */
@Service
@DS("proxyDs")
@Primary
public class EipNozzleServiceImpl extends ServiceImpl<EipNozzleMapper, EipNozzle> implements EipNozzleService {
    @Autowired
    private EipNozzleMapper eipNozzleMapper;

    @Override
    public void saveOne(EipNozzle nozzle) {
        if (nozzle.getCheckResult() != null) {
            String filePath = "/root/" + nozzle.getCheckResult();
            nozzle.setCheckResultObj(UploadFileUtils.uploadFiles(Jpg2Base64Util.Jpg2Base64(filePath)));
            eipNozzleMapper.insert(nozzle);
        } else {
            nozzle.setCheckResultObj(null);
            eipNozzleMapper.insert(nozzle);
        }
    }
}
